<?php

class stSocialMediaToolboxWeeklyReportLog {

    public $config = array();
    public $addOn = array();

    public function __construct($config) {
        $this->config = $config;
        if (empty($this->config ['pluginDir']))
            $this->config ['pluginDir'] = $config['fileDir'] . DIRECTORY_SEPARATOR;

        $this->loadLib();
        $this->excute();
    }

    public function loadLib() {
        $fileDir = $this->config ['fileDir'];
        $version = $this->config ['plugin_version'];
        require_once $fileDir . '/libs/' . $version . '/classes/stcontroller.php';
        require_once $fileDir . '/libs/' . $version . '/classes/stmodel.php';
        require_once $fileDir . '/libs/' . $version . '/classes/stview.php';
        require_once $fileDir . '/libs/' . $version . '/classes/stfunctions.php';
        require_once $fileDir . '/libs/' . $version . '/functions/core.php';
        require_once $fileDir . '/functions.php';
        require_once $fileDir . '/controller.php';
    }

    public function excute() {
        $config = $this->config;
        $controllerName = $config['plugin_name'] . "Controller";
        $controllerObject = new $controllerName($config);
        $controllerObject->cronjobWeeklyReport();
    }

}

$fileDir = dirname(__FILE__);
$dir_file1 = explode(DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR, $fileDir);
define('ABSPATH_FB', $dir_file1[0] . '/');
require_once( ABSPATH_FB . 'wp-load.php' );

$fileDir = dirname(__FILE__);
$fileDir = str_replace(DIRECTORY_SEPARATOR . 'cronjob', '', $fileDir);
$config = include $fileDir . DIRECTORY_SEPARATOR . 'config.php';
$config['fileDir'] = $fileDir;
$pluginClass = new stSocialMediaToolboxWeeklyReportLog($config);
?>